﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 贪吃蛇
{
    enum    E_SceneType   //场景切换枚举
    {
        Begin,
        Game,
        End,
    }
    class Game
    {
        public static ISceneUpdate  nowScene;
        public Game()   // 设置控制台相关内容
        {
            Console.SetWindowSize(80, 20);
            Console.SetBufferSize(80, 20);
        Console.CursorVisible = false;
        ChangeScene(E_SceneType.Begin);
        }
       
        public void Start()
        {
            while (true)
            {
                if(nowScene != null)
                {
                    nowScene.UpDate();    //如果界面不为空的话，就更新
                }
            } 
        }
        
        public static  void ChangeScene(E_SceneType type)  //场景的切换
         {

            Console.Clear();  //清空控制台
            switch (type)
            {
                case E_SceneType.Begin:
                   nowScene = new BeginScene()  ;//new了一个新的场景
                    break;

                case E_SceneType.Game:
                   
                    nowScene = new GameScene();
                    break;
                case E_SceneType.End:
                    nowScene = new EndScene();
                    break;
            }

         }
        }
    }
